import App from './App'
import Vue from 'vue'
import uView from "uview-ui";
import messages from './locale/index'
import '.env.js'
import VueI18n from 'vue-i18n'
import appImage from "@/common/app.image.js"
import store from './store'
import vuexStore from '@/store/$u.mixin.js'
import httpInterceptor from '@/common/http.interceptor.js'
import appInit from '@/common/app.init.js'
import commonApi from '@/common/common.api.js'
import publicJS from '@/common/public.js'
import file from '@/common/http.file.js'
import COS from '@/static/js/COS.js'


// import promptDialog from '@/components/promptDialog/index.js';
// 全局挂载提示框组件
// Vue.prototype.$promptDialog = promptDialog

if (process.env.NODE_ENV === 'development') {
	// var vConsole = new window.VConsole();
}
// 国际化配置
let i18nConfig = {
	silentTranslationWarn: true,
	locale: uni.getLocale(),
	fallbackLocale: 'en', //  没有对应的时候默认英文语言
	messages
}
Vue.use(VueI18n)
const i18n = new VueI18n(i18nConfig)

Vue.use(uView);
Vue.mixin(vuexStore);

//注册js
Vue.prototype.uploadFileOss = (tempFile, model, resolve) => {
	let filename = (new Date().getTime()) + ''
	COS.uploadFileToTencentClound(filename + tempFile.type, tempFile.blob, model).then((res) => {
		console.log(res, process.uniEnv.COSHost);
		resolve({
			fileName: res.split(`${process.uniEnv.COSBucket}.cos.${process.uniEnv.COSRegion}.myqcloud.com/`)[1]
		})
	})
};

App.mpType = 'app'

const app = new Vue({
	i18n,
	store,
	...App
})
Vue.use(publicJS, app)
Vue.use(appImage, app)
Vue.use(httpInterceptor, app)
Vue.use(appInit, app)
Vue.use(commonApi, app)
Vue.use(file, app)
Vue.use(COS, app)
uni.$t = val => app.$t(val) // $t 挂到 uni上 nvue 页面国际化使用
app.$mount()